<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-on 补充</title>
</head>
<!-- 可以为触发的事件传递参数 -->

<body>
    <div id="app">
        <input type="button" value="点击" @click="num(2,3)">
        <!-- 如果只写keyup那么键盘每一次的弹起都会触发，效果较差 -->
        <input type="text" @keyup.enter="doIt($event)">
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        methods: {
            num: function(p1, p2) { //传参时形参要和传递的实参数相同
                alert(p1);
                console.log(p2);
            },
            doIt: function(e) {
                alert("做it")
                console.log(e);
            }
        }
    })
</script>

</html>
